
package com.sgame.android.network;

import android.os.SystemClock;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.HashSet;
import javax.net.ssl.SSLHandshakeException;
import org.apache.http.NoHttpResponseException;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.protocol.HttpContext;

public final class HttpRequestRetry
    implements HttpRequestRetryHandler
{

    public HttpRequestRetry(int i)
    {
        c = i;
    }

    public final boolean retryRequest(IOException exception, int executionCount, HttpContext context)
    {

    	while(true)
        {
            Boolean boolean1;
            boolean flag = (boolean1 = (Boolean)context.getAttribute("http.request_sent")) != null && boolean1.booleanValue();
            if(executionCount <= c && !b.contains(exception.getClass()))
            {
                if(a.contains(exception.getClass()))
                {
                    executionCount = 1;
                    break;
                }
                if(!flag)
                {
                    executionCount = 1;
                    break;
                }
                if(!((HttpUriRequest)context.getAttribute("http.request")).getMethod().equals("POST"))
                {
                    executionCount = 1;
                    break;
                }
            }
            executionCount = 0;
        }
        return executionCount == 1;
    }

    private static HashSet<Object> a;
    private static HashSet<Object> b;
    private final int c;

    static 
    {
        a = new HashSet<Object>();
        b = new HashSet<Object>();
        a.add(org.apache.http.NoHttpResponseException.class);
        a.add(java.net.UnknownHostException.class);
        a.add(java.net.SocketException.class);
        b.add(java.io.InterruptedIOException.class);
        b.add(javax.net.ssl.SSLHandshakeException.class);
    }
}
